package menu.view 
{
	import ui.menu.GeneralItemUI;
	import vo.GeneralVO;
	
	/**
	 * ...
	 * @author WLDragon 2014-03-26
	 */
	public class GeneralItem extends GeneralItemUI 
	{
		
		public function GeneralItem() 
		{
			super();
		}
		
		/**
		 * 更新
		 * @param	g       武将VO
		 * @param	isInner 是否为内政模式
		 */
		public function update(g:GeneralVO,isInner:Boolean = true):void
		{
			if (g == null)
			{
				//结束项
				btName.text = "结束";
				btStrength.text = "";
				btPower.text = "";
				btKnowledge.text = "";
				btLoyalty.text = "";
				btMorality.text = "";
				btExp.text = "";
				btSolider.text = "";
				return;
			}
			
			general = g;
			btName.text = g.name;
			btStrength.text = g.strength.toString();
			btPower.text = g.power.toString();
			btKnowledge.text = g.knowledge.toString();
			btLoyalty.text = g.loyalty == 100 ? "--" : g.loyalty.toString();
			btMorality.text = g.morality.toString();
			btExp.text = g.exp.toString();
			soliders = g.soliders;
			
			selected = false;
			
			if (isInner)
			{
				btMorality.x = 338;
				btExp.x = 400;
				btSolider.visible = false;
				btMorality.visible = true;
			}
			else
			{
				btExp.x = 343;
				btSolider.x = 410;
				btSolider.visible = true;
				btMorality.visible = false;
			}
		}
		
		public function get selected():Boolean 
		{
			return _selected;
		}
		
		public function set selected(value:Boolean):void 
		{
			imgSelected.visible = value;
			_selected = value;
		}
		
		public function get soliders():int 
		{
			return _soliders;
		}
		
		public function set soliders(value:int):void 
		{
			btSolider.text = value.toString();
			_soliders = value;
		}
		
		private var _selected:Boolean;
		private var _soliders:int;
		public var general:GeneralVO;
	}

}